package cn.kgc.vue.controller;

import cn.kgc.vue.commons.QueryCondition;
import cn.kgc.vue.commons.ResponseResult;
import cn.kgc.vue.entity.Schedule;
import cn.kgc.vue.service.ScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 课工场
 * @date 2024/7/10
 * @description  开班计划
 */
@RestController
@RequestMapping("schedule")
@Api(tags = "开班计划")
public class ScheduleController {


    @Resource
    private ScheduleService scheduleService;

    @ApiOperation("开班计划分页")
    @PostMapping("page")
    public ResponseResult schedulePage(@RequestBody QueryCondition<Schedule> queryCondition){

      return scheduleService.schedulePage(queryCondition);

    }

    @ApiOperation("新增/编辑开班计划")
    @PostMapping("addOrUpdate")
    public ResponseResult addOrUpdateSchedule(@RequestBody Schedule schedule){

        boolean b = scheduleService.saveOrUpdate(schedule);
        return   b ? ResponseResult.success():ResponseResult.fail();

    }

    @ApiOperation("删除开班计划")
    @DeleteMapping("delete/{id}")
    public ResponseResult deleteSchedule(@PathVariable("id") Integer id){


        scheduleService.removeById(id);

        return ResponseResult.success().message("删除成功");
    }

}
